import { computed, ref, Ref, watchEffect } from 'vue'
import { TotalData, NumData } from '../types'

/**
 * 预警类型分布
 */
export function useWaringType({ numData }: { numData: Ref<NumData | null> }) {
  const typexAxisData = ref<string[]>([])
  const typeSeriesData = ref<number[]>([])

  watchEffect(() => {
    if (!Array.isArray(numData.value?.levelAreaNum)) {
      return
    }

    typeSeriesData.value = []
    typeSeriesData.value = []

    numData.value?.levelAreaNum.map((item) => {
      typexAxisData.value.push(item.name)
      typeSeriesData.value.push(item.num)
    })
  })
  return {
    typexAxisData,
    typeSeriesData,
  }
}
